/* eslint-disable */
import echarts from 'echarts/lib/echarts'
import 'echarts/lib/chart/line'
import 'echarts/lib/chart/bar'
import 'echarts/lib/component/tooltip'
import {
    LineOption,
    TransverseLineOption,
    BarOption,
} from './option';

import shangjiduban from '@/assets/img/shangjiduban.png'
import shangjipishi from '@/assets/img/shangjipishi.png'
import hotline from '@/assets/img/hotline.png'
import jinjishijian from '@/assets/img/jinjishijian.png'
import bumenyudubanebao from '@/assets/img/duban.png'
import pishi from '@/assets/img/pishi.png'
import bumenyuebao from '@/assets/img/bumenyubao.png'
import bywdb from '@/assets/img/bywdb.png'

import jinxingzhong from '@/assets/img/jinxingzhong.png'
import daijieshou from '@/assets/img/daijieshou.png'
import yichaoshi from '@/assets/img/yichaoshi.png'
import yiwancheng from '@/assets/img/yiwancheng.png'

let myChart1, myChart2, myChart3;
export default {
    data() {
        return {
            currrentDate: '',
            menuItems: [{
                img: shangjiduban,
                name: '上级督办',
                badgeNum: 3
            }, {
                img: shangjipishi,
                name: '上级批示',
                badgeNum: 2
            }, {
                img: hotline,
                name: '12345热线',
                badgeNum: 0
            }, {
                img: jinjishijian,
                name: '紧急事件',
                badgeNum: 1
            }, {
                img: bumenyudubanebao,
                name: '我发起的督办',
                badgeNum: 2
            }, {
                img: pishi,
                name: '我发起的批示',
                badgeNum: 1
            }, {
                img: bumenyuebao,
                name: '部门月报情',
                badgeNum: 4
            }, {
                img: bywdb,
                name: '未达标任务',
                badgeNum: 5
            }],
            tabItems: ['上级任务', '紧急事件', '我发起的', '全部待办', '进行中', '已办结'],
            tabItems2: ['综合经济', '提质增效', '科技创新'],
            todoData: {
                showTable: true,
                items: [{
                    name: '天田机床工具公司车间及生产线改扩建',
                    type: 1,
                    typeName: '督办',
                    date: '2018-10-30',
                    status: 5
                }, {
                    name: ' 固定资产投资指标任务',
                    type: 1,
                    typeName: '批示',
                    date: '2018-10-30',
                    status: 6
                }, {
                    name: '天田机床工具公司',
                    typeName: '批示',
                    type: 2,
                    date: '2018-10-30',
                    status: 5
                }, {
                    name: '固定资产投资指标任务',
                    typeName: '督办',
                    type: 2,
                    date: '2018-10-30',
                    status: 6
                }],
            },
            currentMonthData: {
                showTable: true,
                items: [{
                    filed1: '地区生产总值',
                    filed2: '亿元',
                    filed3: '18.5',
                    filed4: '75',
                    status: 1
                }, {
                    filed1: '规模以上固定资产投资',
                    filed2: '亿元',
                    filed3: '14.0',
                    filed4: '80',
                    status: 2
                }, {
                    filed1: '工业投资',
                    filed2: '亿元',
                    filed3: '8.48',
                    filed4: '82',
                    status: 1
                }, {
                    filed1: '高新技术产业投资',
                    filed2: '万美元',
                    filed3: '300',
                    filed4: '87',
                    status: 2
                }, {
                    filed1: '社会消费品零售总额',
                    filed2: '亿美元',
                    filed3: '0.8',
                    filed4: '50',
                    status: 2
                }]
            },
            hotLineData: {
                showTable: false,
                items: [{
                    filed1: '6月',
                    filed2: 98,
                    filed3: 88,
                    filed4: 81
                }, {
                    filed1: '7月',
                    filed2: 89,
                    filed3: 88,
                    filed4: 80
                }, {
                    filed1: '8月',
                    filed2: 95,
                    filed3: 88,
                    filed4: 85
                }, {
                    filed1: '9月',
                    filed2: 77,
                    filed3: 88,
                    filed4: 75
                }, {
                    filed1: '10月',
                    filed2: 97,
                    filed3: 95,
                    filed4: 95
                }]
            },
            myPublishTaskData: {
                showTable: false,
                items: [{
                    id: 1,
                    type: 1,
                    typeName: '督办',
                    num: 3,
                    status: 1
                }, {
                    id: 2,
                    type: 1,
                    typeName: '督办',
                    num: 5,
                    status: 1
                }, {
                    id: 3,
                    type: 1,
                    typeName: '督办',
                    num: 2,
                    status: 4
                }, {
                    id: 4,
                    type: 1,
                    typeName: '批示',
                    num: 4,
                    status: 2
                }, {
                    id: 5,
                    type: 1,
                    typeName: '批示',
                    num: 3,
                    status: 1
                }, {
                    id: 6,
                    type: 1,
                    typeName: '批示',
                    num: 2,
                    status: 4
                }, {
                    id: 7,
                    type: 1,
                    typeName: '批示',
                    num: 2,
                    status: 4
                }]
            }
        }
    },

    mounted() {
        this.getCurrentDate();
        this.initEchart();

        console.log(process.env.NODE_ENV);
    },
    filters: {
        getImgByStatus(status) {
            if (status == 1) { // 未完成
                return daijieshou;
            }
            if (status == 2) { // 已完成
                return jinxingzhong;
            }
            if (status == 3) { // 超额完成
                return yiwancheng;
            }
            if (status == 4) { // 暂不统计
                return yichaoshi;
            }
            if (status == 5) { // 暂不统计
                return daijieshou;
            }
            if (status == 6) { // 暂不统计
                return jinxingzhong;
            }
        },
        getNameByStatus(status) {
            if (status == 1) { // 未完成
                return '未完成';
            }
            if (status == 2) { // 已完成
                return '已完成';
            }
            if (status == 3) { // 超额完成
                return '超额完成';
            }
            if (status == 4) { // 暂不统计
                return '暂不统计';
            }
            if (status == 5) { // 暂不统计
                return '待接收';
            }
            if (status == 6) { // 暂不统计
                return '进行中';
            }
        }
    },
    methods: {
        tabHandleClick(tab, event) {
            console.log(tab.paneName);
            if (tab.paneName == 0) {
                this.currentMonthData.items = [{
                    filed1: '地区生产总值',
                    filed2: '亿元',
                    filed3: '18.5',
                    filed4: '75',
                    status: 1
                }, {
                    filed1: '固定资产投资',
                    filed2: '亿元',
                    filed3: '14.0',
                    filed4: '80',
                    status: 2
                }, {
                    filed1: '消费品零售总额',
                    filed2: '亿元',
                    filed3: '8.48',
                    filed4: '82',
                    status: 1
                }, {
                    filed1: '外贸进出口总额',
                    filed2: '亿美元',
                    filed3: '0.8',
                    filed4: '50',
                    status: 2
                }, {
                    filed1: '实际利用外资',
                    filed2: '万美元',
                    filed3: '300',
                    filed4: '87',
                    status: 1
                }]
            }
            if (tab.paneName == 1) {
                this.currentMonthData.items = [{
                    filed1: '工业应税销售收入增幅',
                    filed2: '%',
                    filed3: '4',
                    filed4: '16',
                    status: 1
                }, {
                    filed1: '工业增值税增幅',
                    filed2: '%',
                    filed3: '3',
                    filed4: '22',
                    status: 1
                }, {
                    filed1: '企业所得税增幅',
                    filed2: '%',
                    filed3: '3',
                    filed4: '20',
                    status: 2
                }, {
                    filed1: '净增纳税50万元以上企业数',
                    filed2: '个',
                    filed3: '2',
                    filed4: '5',
                    status: 1
                }, {
                    filed1: '净增高新技术企业数',
                    filed2: '个',
                    filed3: '2',
                    filed4: '3',
                    status: 2
                }]
            }
            if (tab.paneName == 2) {
                this.currentMonthData.items = [{
                    filed1: '研发经费支出占GDP比重',
                    filed2: '%',
                    filed3: '2',
                    filed4: '3',
                    status: 1
                }, {
                    filed1: '企业研发经费投入占主营业务收入比重',
                    filed2: '%',
                    filed3: '14.0',
                    filed4: '80',
                    status: 2
                }, {
                    filed1: '万人发明专利拥有量',
                    filed2: '件',
                    filed3: '2',
                    filed4: '28.5',
                    status: 1
                }, {
                    filed1: '高新技术产业产值占规模以上工业产值比重',
                    filed2: '%',
                    filed3: '2',
                    filed4: '61',
                    status: 1
                }, {
                    filed1: '财政科技支出占当年财政支出比例',
                    filed2: '%',
                    filed3: '1',
                    filed4: '10',
                    status: 2
                }]
            }
        },

        getCurrentDate() {
            let date = new Date();
            let weeks = ['日', '一', '二', '三', '四', '五', '六', ];
            this.currrentDate = date.getMonth() + 1 + '月' + date.getDate() + '日  星期' + weeks[date.getDay()];
        },
        deepCopy(obj) {
            var str, newobj = obj.constructor === Array ? [] : {};
            if (typeof obj !== 'object') {
                return;
            } else if (window.JSON) {
                str = JSON.stringify(obj), //系列化对象
                    newobj = JSON.parse(str); //还原
            } else {
                for (var i in obj) {
                    newobj[i] = typeof obj[i] === 'object' ?
                        this.deepCopy(obj[i]) : obj[i];
                }
            }
            return newobj;
        },
        initEchart() {
            myChart1 = echarts.init(this.$refs.echartDiv1)
            const option1 = this.deepCopy(TransverseLineOption);
            option1.series[0].name = '进度';
            option1.yAxis.data = ['地区生产总值', '固定资产投资', '消费品零售总额', '外贸进出口总额', '实际利用外资', '一般公共预算收入']
            option1.series[0].data = [78, 75, 90, 85, 78, 55]
            myChart1.setOption(option1)
            myChart1.resize()

            myChart2 = echarts.init(this.$refs.echartDiv2)
            const option2 = this.deepCopy(BarOption);
            myChart2.setOption(option2)
            myChart2.resize()

            myChart3 = echarts.init(this.$refs.echartDiv3)
            const option3 = this.deepCopy(LineOption);
            myChart3.setOption(option3)
            myChart3.resize()
        },

        switchTable() {
            setTimeout(() => {
                myChart1.resize();
                myChart2.resize();
                myChart3.resize();
            }, 10);
        }
    },
}